#include <iostream>
#include <string>
#include <vector>

int main() {
    int k = 0;
    int ss = 0;
    int j = 0;
    int jj = 0;
    int nn2;
    int nn;

    std::string a, b, c;
    std::cin >> a >> b >> c;

    std::vector<std::string> numbers = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};

    if (std::find(numbers.begin(), numbers.end(), a) == numbers.end() || std::find(numbers.begin(), numbers.end(), b) == numbers.end() || std::find(numbers.begin(), numbers.end(), c) == numbers.end()) {
        std::cout << "Wrong input" << std::endl;
    } else {
        std::string n0 = "zero";
        std::string n1 = "one";
        std::string n2 = "two";
        std::string n3 = "three";
        std::string n4 = "four";
        std::string n5 = "five";
        std::string n6 = "six";
        std::string n7 = "seven";
        std::string n8 = "eight";
        std::string n9 = "nine";

        if (a == n0) {
            a = "0";
        } else if (a == n1) {
            a = "1";
        } else if (a == n2) {
            a = "2";
        } else if (a == n3) {
            a = "3";
        } else if (a == n4) {
            a = "4";
        } else if (a == n5) {
            a = "5";
        } else if (a == n6) {
            a = "6";
        } else if (a == n7) {
            a = "7";
        } else if (a == n8) {
            a = "8";
        } else if (a == n9) {
            a = "9";
        }

        if (b == n0) {
            b = "0";
        } else if (b == n1) {
            b = "1";
        } else if (b == n2) {
            b = "2";
        } else if (b == n3) {
            b = "3";
        } else if (b == n4) {
            b = "4";
        } else if (b == n5) {
            b = "5";
        } else if (b == n6) {
            b = "6";
        } else if (b == n7) {
            b = "7";
        } else if (b == n8) {
            b = "8";
        } else if (b == n9) {
            b = "9";
        }

        if (c == n0) {
            c = "0";
        } else if (c == n1) {
            c = "1";
        } else if (c == n2) {
            c = "2";
        } else if (c == n3) {
            c = "3";
        } else if (c == n4) {
            c = "4";
        } else if (c == n5) {
            c = "5";
        } else if (c == n6) {
            c = "6";
        } else if (c == n7) {
            c = "7";
        } else if (c == n8) {
            c = "8";
        } else if (c == n9) {
            c = "9";
        }

        int nd = std::stoi(a + b + c);
        int n = nd;
        std::string nw = std::to_string(n);

        int length = nw.length();
        if (length < 3) {
            std::cout << "Wrong input" << std::endl;
        } else {
            auto is_prime = [](int n) {
                if (n <= 1) {
                    return false;
                }
                if (n <= 3) {
                    return true;
                }
                if (n % 2 == 0 || n % 3 == 0) {
                    return false;
                }
                int i = 5;
                while (i * i <= n) {
                    if (n % i == 0 || n % (i + 2) == 0) {
                        return false;
                    }
                    i += 6;
                }
                return true;
            };

            while (ss != 1) {
                if (is_prime(n)) {
                     nn = n;
                    ss = 1;
                } else {
                    n -= 1;
                    j += 1;
                }
            }
            n = nd;
            ss = 0;
            while (ss != 1) {
                if (is_prime(n)) {
                    nn2 = n;
                    ss = 1;
                } else {
                    n += 1;
                    jj += 1;
                }
            }
            if (j > jj) {
                std::cout << nn2 << std::endl;
            } else {
                std::cout << nn << std::endl;
            }
        }
    }

    return 0;
}